<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
    <style>
        * {
            margin: 0;
            padding: 0;
            outline: none;
            box-sizing: border-box;
            font-family: 'Montserrat', sans-serif;
        }

        body {
            background-color: #f2f2f2;
        }

        nav {
            background-color: #171c24;
            display: flex;
            flex-wrap: wrap;
            align-items: center;
            justify-content: space-between;
            height: 70px;
            padding: 0 100px;
        }

        nav .logo {
            color: #fff;
            font-size: 30px;
            font-weight: 600;
            letter-spacing: -1px;
        }

        nav .nav-items {
            display: flex;
            flex: 1;
            list-style: none;
            padding: 0 0 0 40px;
        }

        nav .nav-items li {
            padding: 0 15px;
        }

        nav .nav-items li a {
            color: #fff;
            font-size: 18px;
            font-weight: 500;
            text-decoration: none;
            transition: 1s;
        }

        nav .nav-items li a:hover {
            color: #ff3d00;
        }

        nav form {
            display: flex;
            height: 40px;
            border-radius: 2px;
            padding: 2px;
            background-color: #1e232b;
            min-width: 18% !important;
            border: 1px solid rgba(155, 155, 155, .2);
        }

        nav form .search-data {
            height: 100%;
            width: 100%;
            padding: 0 10px;
            color: #fff;
            font-weight: 500;
            background: none;
            border: none;
            font-size: 17px;
        }

        nav form button {
            padding: 0 15px;
            background: #ff3d00;
            border: none;
            cursor: pointer;
            font-size: 17px;
            color: #fff;
            border-radius: 2px;
        }

        nav .menu-icon,
        nav .search-icon,
        nav .cancel-icon {
            width: 40px;
            color: #fff;
            text-align: center;
            margin: 0 50px;
            font-size: 18px;
            cursor: pointer;
            display: none;
        }

        nav .menu-icon span,
        nav .search-icon,
        nav .cancel-icon {
            display: none;
        }

        @media (max-width: 1245px) {
            nav {
                padding: 0 50px;
            }
        }

        @media (max-width: 1140px) {
            nav {
                padding: 0;
            }

            nav .logo {
                flex: 2;
                text-align: center;
            }

            nav .nav-items {
                position: fixed;
                z-index: 99;
                top: 70px;
                width: 100%;
                left: -100%;
                height: 100%;
                background: #14141f;
                display: inline-block;
                padding: 10px 50px 0 50px;
                text-align: center;
                transition: left 0.3s ease;
            }

            nav .nav-items.active {
                left: 0%;
            }

            nav .nav-items li {
                line-height: 40px;
                margin: 30px 0;
            }

            nav .nav-items li a {
                font-size: 20px;
            }

            nav form {
                position: absolute;
                top: 80px;
                right: 50px;
                opacity: 0;
                pointer-events: none;
                transition: top 0.3s ease, opacity 0.1s ease;
            }

            nav form.active {
                opacity: 1;
                top: 95px;
                pointer-events: auto;
            }

            nav form::before {
                position: absolute;
                content: '';
                top: -13px;
                right: 0;
                width: 0;
                height: 0;
                z-index: -1;
                margin: -20px 0 0;
                border: 10px solid transparent;
                border-bottom-color: #1e232b;
            }

            nav form::after {
                position: absolute;
                content: '';
                height: 60px;
                width: calc(100% + 20px);
                padding: 2px;
                border-radius: 2px;
                background: #1e232b;
                z-index: -2;
                left: 50%;
                top: 50%;
                transform: translate(-50%, -50%);
            }

            nav .menu-icon {
                display: block;
            }


            nav .search-icon,
            nav .menu-icon span {
                display: block;
            }

            nav .search-icon.hide,
            nav .menu-icon.hide {
                display: none;
            }

            nav .cancel-icon.show {
                display: block;
            }
        }

        @media (max-width: 350px) {

            nav .search-icon,
            nav .cancel-icon,
            nav .menu-icon {
                margin: 0 10px;
                font-size: 16px;
            }
        }
    </style>
</head>

<body>
    <nav>
        <div class="menu-icon"><span class="fa fa-bars"></span></div>
        <div class="logo">CodingNepal</div>
        <div class="nav-items">
            <li><a href="#">Home</a></li>
            <li><a href="#">About</a></li>
            <li><a href="#">Blogs</a></li>
            <li><a href="#">Contact</a></li>
            <li><a href="#">Feedback</a></li>
        </div>
        <div class="search-icon"><span class="fa fa-search"></span></div>
        <div class="cancel-icon"><span class="fa fa-times"></span></div>
        <form action="#">
            <input type="search" class="search-data" placeholder="Search" required>
            <button type="submit" class="fa fa-search"></button>
        </form>
    </nav>
    <script>
        const menuBtn = document.querySelector(".menu-icon span")
        const searchBtn = document.querySelector(".search-icon")
        const cancelBtn = document.querySelector(".cancel-icon")
        const items = document.querySelector(".nav-items")
        const form = document.querySelector("form")
        menuBtn.onclick = () => {
            items.classList.add("active");
            menuBtn.classList.add("hide");
            searchBtn.classList.add("hide");
            cancelBtn.classList.add("show");
        }
        cancelBtn.onclick = () => {
            items.classList.remove("active");
            menuBtn.classList.remove("hide");
            searchBtn.classList.remove("hide");
            cancelBtn.classList.remove("show");
            form.classList.remove("active");
            cancelBtn.style.color = "#ff3d00";
        }
        searchBtn.onclick = () => {
            form.classList.add("active");
            searchBtn.classList.add("hide");
            cancelBtn.classList.add("show");
        }
    </script>
</body>

</html>